using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SoundCtrollor : MonoBehaviour
{
    public AudioClip[] audioCp;
    public bool Loop = false;
    public float SoundVolume;
    private static AudioSource audioSrc;
    private bool CanPlay = true;
    public void Start()
    {
        audioSrc = GetComponent<AudioSource>();
        if(Loop)audioSrc.PlayOneShot(audioCp[0]);
    }

    public void LateUpdate() {
        if(Loop && CanPlay){
            StartCoroutine(LoopSound(13.5f,audioCp[0]));
        }
    }
    IEnumerator LoopSound(float Length,AudioClip Acp){
        CanPlay = false;
        yield return new WaitForSeconds(Length);
        CanPlay = true;
        audioSrc.PlayOneShot(Acp);
    }
    public static void ChangeVolume(float SV){
        audioSrc.volume = SV;
        
    }
}
